import os
from datetime import datetime

from dotenv import load_dotenv
from processors.video_processor import process_chapter

# 加载环境变量
load_dotenv()

def main():
    # 从环境变量获取API密钥
    api_key = os.environ.get("ARK_API_KEY")
    if not api_key:
        print("❌ 错误: 未设置 ARK_API_KEY 环境变量")
        return
    
    chapter_content = """"Prologue

(**Author's Note**: **Untouchable, Book 1 of the Moonlight Avatar Series contains details of the following subjects: abuse, trauma, suicide, recovery from trauma, and emotional relapse**. **This book and series is not suitable for all readers**. **While the subject of the supernatural, werewolves, and magic is the focal point of the story, the series will follow the effects of trauma and abandonment associated with the main female lead**. **If you are easily triggered by any of the mentioned subjects, do not read ahead for your mental health**. **This is your only warning**. **Read at your own risk**.)
**Blood**.
Crimson liquid coated my face, seeping from the open wound on my forehead. Its metallic taste mixed with the saltiness of my tears served as a reminder of my earlier beating. My body throbbed as the phantom fists and steel-toed shoes make their home in my flesh as if the beating was still happening. With every movement of my limbs, agony shots through my fragile body until I took refuge in the dirtied corner of my cell.
The cell I called home for years. It had witnessed the maturation of a frightened young child to an equally frightened teenager. Sometimes, I forget the walls had witnessed more atrocities committed against my body than I could remember.
Why am I here? I suppose you could say I was a criminal. An *accused* criminal. My pack was convinced that I was the one responsible for my Luna and her daughter’s death eight years ago. Ever since that day, I was reminded of how much of a disgrace I was to all werewolf kind. I endured their fiery rage with each blow to my now emaciated body. Each bruise and cut on my muting brown skin were messages that all harmoniously said the same thing.
*You deserve to suffer*.
No matter how much I screamed or cried, my pleas of innocence fell on deaf ears. No one wanted to believe my side of the story. I still remember that day as if it happened yesterday, for it had burned itself to the forefront of my mind.
Nuria Prince was the daughter of the great Alpha Jonathan Prince and Luna Celeste Johansen-Prince. She was also my best friend. My father, Steven Lane, and mother, Ashley Lane, were Alpha Jonathan’s Beta and Beta Female. Our families were close with each other, including the Gammas, Omar, and Amani Dubois. Nuria and I were like two peas in a pod. Our mothers raised us together, and our bond strengthened from there. We did everything together that young girls did; we played with dolls, went to the same school, had sleepovers in each other’s rooms, and more. If one of us were around, the other was not too far behind. I would even say that I was closer to Nuria than I was to Raina, my older sister, or Neron, her older brother. Don’t get me wrong, I still loved Raina very much, but the two-year gap between us, she wanted to be with kids her age.
Nuria had the sweet innocence of her mother and held the air of authority like her father. Over time, the pack began calling her an angel, which formed her new title of Angel of the Pack. Her smile and laughter were infectious. She could brighten up your gloomiest days with a smile or a giggle.
Angels were beautiful, and Nuria was a beauty. Her long black hair traversed down to the middle of her back, inheriting it from her mother. Her blue eyes rivaled the bluest of skies. Her chubby cheeks were so squeezable, which I would do whenever she got on my nerves. I was proud to call Nuria my sister. I knew we would grow up to be an unstoppable duo. The Alpha’s and Beta’s daughters together? It was a dream team made by the moon goddess herself.
On that fateful day, when we were nine years old, I felt daring—the complete opposite of my normally shy demeanor. Nuria was the courageous one, no doubt ingrained in her alpha genes. I came up with the idea to push aside the rules for us to play at our favorite place: a pond deep in the oak forest. We would go there to play tag, make mud pies, or dream about what our wolves looked like. Our parents warned us to never go into the woods alone because of potential rogue attacks. However, we were a rebellious pair and did the opposite of what we were told.
We believed we were untouchable.
Our older siblings were off doing whatever pre-teens did, so, like the disobedient pair we were, we went off.
Not long after that, Luna Celeste, or Aunt Essie, as I affectionately called by, followed us and reprimanded both of us for sneaking away against their orders. But Nuria and I had our fun, and we would do it again. Aunt Essie knew that by the look she gave us.
That should have been the end of it. We should’ve gone back to the pack house, and continued to live our best lives, but fate had a sickening way of creeping up on unsuspecting people.
I should’ve taken our parents’ warnings seriously. Being daring also came with stupidity, and I was very stupid that day. There hadn’t been attacks for a couple of months up to that point, so I genuinely thought we were safe. It was only when more than a dozen of those disgusting dogs rushed in from all angles around us was when I understood we were *never* safe.
“Girls, run home, now! Don’t stop until you get there!” Aunt Essie screamed at us before shifting into a beautiful black wolf, ready to protect us with all her power.
Nuria and I ran for our lives. We grabbed each other’s hands and ran as fast as our little legs could carry us.
But we didn’t get far before a rogue, larger than life with nothing to lose, tore us apart from each other. **Literally**. I remember looking back to see the biggest of the rogues, their leader, tear into my aunt like she was a piece of paper. The brown rogue who separated Nuria from me had no remorse or consciousness with the way he plunged his claw into her small body. The screams from Nuria and Aunt Essie were forever seared into my mind as their innocent blood coated the dense forest floor. I, for some reason, was left alive that day, but not without a deep bite into my right arm.
The leader, a large werewolf shifted into human form walked up to me with the blood of the Luna dripping from his hand, face, and jaws. He reached out and painted my face in their blood, laughing. I would never forget those deep blue, almost bloodshot eyes staring deep into my quivering soul.
I lost my best friend. I lost my aunt. Their mangled bodies, void of life, were left in pools of their blood. And all I could do was stare. Nothing registered in my mind. I still felt the fleeting warmth of Nuria’s hand in my own.
*She isn’t dead*! *She couldn’t be dead*!
*Right*?
What happened after played like a nightmare. The calvary arrived too late to the scene because the attack happened without warning. A horn, normally sounded by the patrols of an incoming attack, didn’t sound. Later, it was learned the rogues killed off the patrols, adding to the death toll. I heard the heartbroken howl of Alpha Jonathan as the mate bond between him and Luna Celeste shriveled and died. I listened to the cries of Neron as he mourned over the loss of his mother and baby sister and the shattered howls of all pack members. Later that day, the leaders of Zircon Moon informed all the neighboring packs of the tragic loss after cleaning up the horrific scene.
Then, all eyes turned to me. The little girl covered in the blood of both mother and child. I, the sole survivor of this massacre, the one who shouldn’t have lived, was now the one the blame fell upon, demanding why I didn’t die.
Why did I, a pup of the Beta, get to live, while our Luna and Angel, had to die?
But no one knew the pain I felt from watching my best friend get mauled to death or the distant cries of the Luna who couldn’t handle the onslaught on her own. Neron stared at me with so unbearable sadness. Alpha Jonathan scowled at me with so much revulsion that my child-mind couldn’t comprehend the heat of his rage. But it isn’t just his hate. It was hatred from the entire pack, including my parents and older sister.
Once they learned it was my idea for Nuria and me to go to the pond, my fate was sealed.
On that day, I didn’t just lose Nuria and Aunt Essie. I lost my pack and my family, who never looked at me the same way again. I was officially branded as a speck of werewolf excrement. I, Halima Lane, was branded a *criminal*.
Over time, Neron grew to hate me too, not that I blame him. It was my fault he lost half his family.
Flash forward to today, eight years later. I washere in a prison cell made only for the lowest of all werewolf kind. In the distance were other cells where the guards would place other criminals and rogues to interrogate and torture them. To be placed in the same dungeon as actual beasts said a lot about how I was viewed by this pack.
If the guards were bored, however, they would play their “games” with me. No one could stop them, or if they could, they didn’t want to. They’d cut me up and beat me, just to see how much I could endure before I passed out.
Yet, that wasn’t the worst of it. There was one guard I hated the most and was terrified of the most. He took *his* game to another level. They were different games than what I was used to, starting when I was fourteen, but, as I got older, I understood what the games meant.
Those games left me broke, bruised, and dirty.
When I wasn’t down here in the bitter cold, I was expected to perform labor as the pack slave. That’s the only reason Alpha Jonathan hadn’t executed me yet. Scrubbing the pack house floors from top to bottom, doing the laundry, and washing the dishes were just a few of my duties. Allowing me anywhere near the food was forbidden, for they feared I would poison the pack.
Rumors held more weight against the defenseless.
The Omegas oversaw the cooking. Their hateful stares were nothing new to me. Taking one step into the pack kitchen was equivalent to spitting on their faces. Washing the dishes was the only time they allowed me in the kitchen, and they expected each dish to be spotless. With each missed spot, Cassandra, the head cook, and Lead Omega would strike me with a weapon of her choice, including knives. Sometimes, the other Omegas would sabotage my work on purpose, so they’d watch me get beaten. My pain became their entertainment and judging by their sinister smiles, they weren’t planning on stopping anytime soon.
Sometimes, the beatings were so severe that I had to be treated by the pack doctor. But he was just like the rest of the pack. He, too, blamed me for the loss. He’d give me mild pain medication and send me on my way. Not once has he dressed my wounds. They were left to fester and heal on their own. My body was littered with old and new scars that never got the proper treatment they needed.
I wasn’t allowed a day off; the Alpha determined I was unworthy of leisure. I worked without rest from sunrise to sunset, hands in a bucket of soapy water, on my knees scrubbing away filth from the pristine floors. There was never a dull moment when my bucket was knocked over, or I was pushed into it, or if I randomly got struck in the face or the back by a random member. Slaves were supposed to be abused. They’re servants while simultaneously serving as punching bags. That was my fate.
I had to endure it all. I wasn’t allowed to scream, cry, or beg. I was Zircon Moon’s silent doll. Dolls don’t speak or complain; they take whatever treatment they rightfully deserve. But actual dolls were treated better than me. If a young pup ruins their doll, their mother could stitch them back up and they’re okay again. The pup was happy until the next tear.
I didn’t have anyone to stitch me back up. My mother had forsaken that duty and my father acted as though I didn’t exist. Raina, my once-beloved sister, partook in my torment, along with her friends. As an older sister, one would think she wouldn’t hesitate to protect me, but she found immense pleasure in hurting me.
But I couldn’t say that their abandonment hurts anymore. The beatings felt the same to me unless it was from Alpha Jonathan or Neron. Given their status and the amount of power that flowed through their Alpha blood, their brutality was enough to leave me incapacitated for several days.
They blame me for the fall of their family. To them, I was the one who ripped the heart out of our pack. However, deep down, I believed they knew I was innocent, but they needed a scapegoat for their wrathful feelings, and I fit the bill.
Despite all the pain I was put through, I still had hope. Hope that one day I would find my mate, the other half to my soul. Every wolf had a mate—their eternal lover, matched by the Moon Goddess herself. I hope my mate, whoever he or she was, would take me out of this hellhole and love me for me.
That was all I wish for. That little smidgen of happiness through the mate bond.
*Please, Moon Goddess*. *Grant me that happiness, save me from this place*.
*Please*…
"""
    start_time = datetime.now()
    result = process_chapter(chapter_content, api_key)
    end_time = datetime.now()
    print("start time:" + str(start_time))
    print("end time:" + str(end_time))
    print("\n" + "=" * 60)
    print("🎬 视频生成完成!")
    print("使用时长：" + str(end_time - start_time))
    print("=" * 60)

    if result["success"]:
        print(f"✅ 成功生成视频")
        print(f"📁 输出文件夹: {result['output_dir']}")
        print(f"🕐 生成时间戳: {result['timestamp']}")
        print(f"📽️ 最终视频: {result.get('output_file', '单段视频')}")
        print(f"🎞️ 视频段数: {result['segments_count']}")
        print(f"📝 段落数: {result['paragraphs_count']}")
    else:
        print(f"❌ 生成失败: {result['error']}")
        print(f"📁 输出文件夹: {result.get('output_dir', '未创建')}")

    print("=" * 60)


if __name__ == "__main__":
    main()
